WDV221 Intro Javascript

Unit-3 - Functions and the String Object


Please complete the following exercises on this page. When complete post this page to your server. Make a link in your WDV221 homework page for this assignment.

Submit this assignment on Blackboard. Please include a link to your homework page.


1. Define a global variable called inName. Assign it an initial value of "".

2. Define a global variable called emailAddress and assign it the value of your DMACC email address.

NOTE: These variables should be available to any script on this page including within any functions since they have global scope.

3. Create a function called getName( ). The function will use a prompt to ask the user to enter a name. Store the result in the inName variable. Create a button with an onclick event handler to activate this function.

Click to change inName variable value to the user will enter value through prompt.

4. Create a function called displayName( ). The function will use alert( ) to display the value stored in the inName variable. Create a button with an onclick event handler to activate this function.

Click to display the inName variable value that the user entered through the prompt.

5. Create a function called getEmail( ). The function will use a prompt( ) to ask the user to input an email address. Store the input in the global variable emailAddress. Create a button with an onclick event handler to activate this function.

Click to change the emailAddress variable value to the value the user will enter through the prompt.

6. Create a function called displayEmailName( ). The function will display the name portion of the email address stored in the yourEmailAddress variable. Create a button with an onclick event handler to activate this function.

For example: Assign emailAddress variable a value of "aStudent@dmacc.edu". This function should return display "aStudent".

7. Create a function called displayEmailServer( ). The function will display the email server name after the @ symbol. Create a button with an onclick event handler to activate this function.

For example: Given the same value for emailAddress variable. This function should display "dmacc.edu". Do not include the @ symbol.

Click here to access my Javascript Home Work Page

Click here to access my Javascript Home Page